package edu.chinasoft.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.annotation.WebServlet;
import org.apache.log4j.Logger;

/**
 *
 * @author mhao
 * @date 2020年2月12日:下午3:56:48
 * @version V1.0
 * @Description: 
*/
@WebServlet(name = "myShowTimeForServlet", value = "/servlet/showtimeforservlet")
public class ShowTimeForServlet extends HttpServlet {
	private static Logger logger = Logger.getLogger(ShowTimeForServlet.class);

	/**
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		logger.debug(" ShowTimeForServlet >doGet start.......");
		response.setContentType("text/html;charset=utf-8");
		request.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		//获取当前时间
		Date date = new Date();
		out.write(date.toLocaleString());
		try {
			Thread.sleep(3*1000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		logger.debug(" ShowTimeForServlet >doGet end.......");
	}

	/**
	 *
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		logger.debug(" ShowTimeForServlet >doPost start.......");
		this.doGet(request, response);
		logger.debug(" ShowTimeForServlet >doPost end.......");
	}

}